//    Copyright (c) 2009 Elwyn Malethan
//
//    This file is part of SeemoreJ.
//
//    SeemoreJ is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    SeemoreJ is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with SeemoreJ.  If not, see <http://www.gnu.org/licenses/>.

package com.malethan.seemorej.taglib.elements;

import com.malethan.seemorej.taglib.Util;

public abstract class BaseInputElement extends BaseElement {
    //----------------------------------------------------------------------- Static Properties and Constants
    //----------------------------------------------------------------------- Static Methods
    //----------------------------------------------------------------------- Instance Properties
    //----------------------------------------------------------------------- Constructors

    protected BaseInputElement(String elementName) {
        super(elementName);
    }

    //----------------------------------------------------------------------- Getters and Setters
    //----------------------------------------------------------------------- Instance Methods

    /**
     * Implementations should return the HTML for the element
     *
     * @return a string representation of the object.
     */
    public String toString() {
        StringBuffer html = new StringBuffer("<input");
        Util.appendAttribute(html, "type", elementName);
        Util.appendAttribute(html, "value", this.value!= null ? String.valueOf(this.value) : "");
        appendAttributes(html, this, getAttributes());
        html.append(" />");
        return html.toString();
    }

    public abstract String[] getAttributes();
}
